//
//  ViewController.m
//  day02
//
//  Created by dllo on 16/6/4.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"
#import "LYLabel.h"
#import "LYTextField.h"
#import "LYButton.h"

/*
 需求:
 1. 键盘能够回收,提示点击按钮的时候键盘能回收,核心代码:[输入框
 resignFirstResponder];
 2. 密码和确认密码设置密文输入
 3. 手机号使用数字键盘
 */

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self creatField];
    [self creatLabel];
    [self creatButton];
    
}


-(void)creatLabel
{
    LYLabel *nameLabel = [[LYLabel alloc]initWithFrame:CGRectMake(50, 50, 100, 50) withText:@"用户名"];
    [self.view addSubview:nameLabel];
    
    LYLabel *passwordLabel = [[LYLabel alloc]initWithFrame:CGRectMake(50, 100, 100, 50) withText:@"密码" ];
    [self.view addSubview:passwordLabel];
    
    LYLabel *confirmLabel = [[LYLabel alloc]initWithFrame:CGRectMake(50, 150, 100, 50) withText:@"确认密码"];
    [self.view addSubview:confirmLabel];
    
    LYLabel *phoneLabel = [[LYLabel alloc]initWithFrame:CGRectMake(50, 200, 100, 50) withText:@"手机号" ];
    [self.view addSubview:phoneLabel];
    
    LYLabel *emailLabel = [[LYLabel alloc]initWithFrame:CGRectMake(50, 250, 100, 50) withText:@"邮箱"];
    [self.view addSubview:emailLabel];
    
    [nameLabel release];
    [passwordLabel release];
    [confirmLabel release];
    [phoneLabel release];
    [emailLabel release];
    
}

-(void)creatField
{
    LYTextField *nameField = [[LYTextField alloc]initWithFrame:CGRectMake(200, 50, 300, 50) withPlaceholder:@"请输入用户名"];
    [self.view addSubview:nameField];
    
    LYTextField *passwordField = [[LYTextField alloc]initWithFrame:CGRectMake(200, 100, 300, 50) withPlaceholder:@"请输入密码"];
    passwordField.secureTextEntry = YES;
    [self.view addSubview:passwordField];

    LYTextField *confirmField  = [[LYTextField alloc]initWithFrame:CGRectMake(200, 150, 150, 50) withPlaceholder:@"再次输入密码"];
    confirmField.secureTextEntry = YES;
    [self.view addSubview:confirmField];
    
    LYTextField *phoneField = [[LYTextField alloc]initWithFrame:CGRectMake(200, 200, 300, 50) withPlaceholder:@"请输入联系方式"];
    phoneField.keyboardType = UIKeyboardTypeNumberPad;
    [self.view addSubview:phoneField];

    LYTextField *emailField = [[LYTextField alloc]initWithFrame:CGRectMake(200, 250, 300, 50) withPlaceholder:@"请输入邮箱"];
    [self.view addSubview:emailField];
    
    [nameField release];
    [passwordField release];
    [confirmField release];
    [phoneField release];
    [emailField release];
    
    [self.view endEditing:YES];

}

-(void)creatButton
{
    LYButton *reButton = [LYButton buttonWithFrame:CGRectMake(50, 300, 50, 50) withText:@"注册"];
    [self.view addSubview:reButton];
    [reButton release];
    
    LYButton *cancelButton = [LYButton buttonWithFrame:CGRectMake(200, 300, 50, 50) withText:@"取消"];
    [self.view addSubview:cancelButton];
    [cancelButton release];

}


@end
